Skip to content

[jsweep] Clean update_pr_description_helpers.cjs#40584

Merged
pelikhan merged 3 commits into
mainfrom
signed/jsweep/update-pr-description-helpers-534ca1ebf215d391
Jun 21, 2026
Merged

[jsweep] Clean update_pr_description_helpers.cjs#40584
pelikhan merged 3 commits into
mainfrom
signed/jsweep/update-pr-description-helpers-534ca1ebf215d391

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Minor code-quality sweep on update_pr_description_helpers.cjs: replaces a method-chained property access with object destructuring and converts a string concatenation to a template literal. Companion test additions expand coverage for buildAIFooter and findIsland.


Changes

actions/setup/js/update_pr_description_helpers.cjs — refactor (low impact)

  • Destructuring over chaining: detectionCaution is now extracted via object destructuring instead of a chained property access, improving readability.
  • Template literal: string concatenation replaced with a template literal at the relevant callsite.
  • No behaviour change; no breaking surface.

actions/setup/js/update_pr_description_helpers.test.cjs — tests (low impact)

  • buildAIFooter: new cases cover history-URL inclusion and guaranteed non-empty output.
  • findIsland: new cases cover full-body span match, empty-body input, and prefix-content edge cases.

Risk assessment

Dimension Rating Notes
Behaviour change None Pure refactor + test additions
Breaking change No
Test coverage delta Positive New cases for two helpers
Review effort Low Mechanical cleanup

Commit trail

SHA Message
7772a4ab0 jsweep: clean update_pr_description_helpers.cjs
dc0ceb209 Merge branch main into branch
47b5ac7a5 Merge branch main into branch

Generated by PR Description Updater for issue #40584 · 39.3 AIC · ⌖ 6.74 AIC · ⊞ 4.5K ·

- Destructure detectionCaution directly from assembleMarkdownBodyParts result
- Use template literal for contentWithCaution string building
- Add 10 new tests (45 total, up from 35):
  - findIsland: exact startIndex/endIndex values, empty body, prefix content
  - buildAIFooter: historyUrl parameter, non-empty string assertion

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review June 21, 2026 05:50
Copilot AI review requested due to automatic review settings June 21, 2026 05:50
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #40584 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold is 100). Affected files are skill scripts and an MCP server helper, not core business logic.

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR performs a small cleanup in update_pr_description_helpers.cjs and expands unit tests around footer generation and island detection, aligning with the repo’s ongoing jsweep maintenance work.

Changes:

  • Refactors CAUTION extraction to destructure detectionCaution from assembleMarkdownBodyParts() results.
  • Switches CAUTION content assembly to a template literal for readability.
  • Adds new tests for buildAIFooter and findIsland to cover additional edge cases and assertions.
Show a summary per file
File Description
actions/setup/js/update_pr_description_helpers.cjs Minor refactor of CAUTION extraction/assembly without changing behavior.
actions/setup/js/update_pr_description_helpers.test.cjs Adds coverage for buildAIFooter history URL propagation and additional findIsland index edge cases.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@github-actions github-actions Bot mentioned this pull request Jun 21, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /tdd and /zoom-out — commenting with two non-blocking observations on test quality.

📋 Key Themes & Highlights

Key Themes

  • Untested truthy branch: updateBody's detectionCaution injection path (the code actually touched by this PR) has no test exercising a non-empty caution value — this gap pre-dates the PR but is worth closing.
  • Redundant baseline test: should return a non-empty footer string checks typeof === 'string' and length > 0, both already implied by the richer toContain tests above it.

Positive Highlights

  • ✅ Destructuring over chained property access is idiomatic and cleaner.
  • ✅ Template literal replaces string concatenation consistently with the rest of the file.
  • ✅ New findIsland tests are precise and well-chosen: boundary (startIndex=0), empty body (-1 indices), and prefix-offset correctness all fill real gaps.
  • historyUrl optional parameter propagation now has an explicit test.
  • ✅ All 45 tests pass with format/lint/typecheck green.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 66.3 AIC · ⌖ 7.45 AIC · ⊞ 6.9K


it("should return a non-empty footer string", () => {
const footer = buildAIFooter("Test Workflow", "https://github.com/owner/repo/actions/runs/123");
expect(typeof footer).toBe("string");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The typeof footer === 'string' assertion is redundant — earlier tests already imply the return type via .toContain(), and the JSDoc @returns {string} documents the contract.

💡 Consider a behavioural assertion instead

A more valuable spec would verify something the other tests don't cover, for example that a footer produced with no optional args still contains the mandatory attribution marker. The current check reads as a type-level sanity probe rather than a specification.

}).detectionCaution;
const contentWithCaution = detectionCaution ? detectionCaution + "\n\n" + sanitizedNewContent : sanitizedNewContent;
});
const contentWithCaution = detectionCaution ? `${detectionCaution}\n\n${sanitizedNewContent}` : sanitizedNewContent;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The detectionCaution truthy branch — ${detectionCaution}\n\n${sanitizedNewContent} — has no test coverage. The PR adds tests for findIsland and buildAIFooter, but the code path that was actually changed (updateBody's caution injection) is never exercised with a non-empty detectionCaution.

💡 Suggested test scaffold

To cover this branch you would need to mock assembleMarkdownBodyParts to return a non-empty detectionCaution, then assert the output starts with the caution block followed by the sanitized content:

it('should prepend detectionCaution before content when threat is detected', () => {
  // mock markdown_body_helpers to return detectionCaution = '>  [!CAUTION]\n> ...'
  const result = updateBody({ ...baseParams, operation: 'replace' });
  expect(result.indexOf(caution)).toBeLessThan(result.indexOf('New content'));
});

Without this test the template-literal on this line is validated only by visual inspection.

@github-actions

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 78/100 — Acceptable

Analyzed 5 test(s) across 1 JavaScript file: 5 design, 0 implementation, 0 guideline violation(s).

📊 Metrics & Test Classification (5 tests analyzed)
Metric Value
New/modified tests analyzed 5
✅ Design tests (behavioral contracts) 5 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 3 (60%)
Duplicate test clusters 0
Test inflation detected YES — update_pr_description_helpers.test.cjs +40 lines vs production +3 lines (≈13× ratio; threshold 2×)
🚨 Coding-guideline violations 0
Test File Classification Issues Detected
should include historyUrl in footer when provided update_pr_description_helpers.test.cjs ✅ Design
should return a non-empty footer string update_pr_description_helpers.test.cjs ✅ Design Happy-path only; basic sanity check
should return exact startIndex=0 and endIndex=body.length... update_pr_description_helpers.test.cjs ✅ Design (boundary)
should not find island in empty body update_pr_description_helpers.test.cjs ✅ Design (edge case)
should find island with prefix content and return correct startIndex update_pr_description_helpers.test.cjs ✅ Design (boundary)

Go: 0 (*_test.go); JavaScript: 5 (*.test.cjs, *.test.js). No other languages detected.

⚠️ Flagged Tests — Non-blocking Notes (1 item)

Test inflation (actions/setup/js/update_pr_description_helpers.test.cjs): The test file grew by +40 lines while the production file changed by only +3 lines (≈13× ratio, threshold 2×). This triggers the binary inflation penalty (−10 pts). The inflation is contextually expected — the production change was a code-style cleanup (destructuring + template literal), and the new tests are adding coverage for pre-existing buildAIFooter and findIsland behaviors. No action required, but the pattern is noted per scoring rules.

should return a non-empty footer string: Asserts typeof footer === "string" and footer.length > 0. These are trivially satisfied by every other test in the suite that already calls the same function — consider folding this into an existing parametric test or removing it to avoid noise.

Verdict

Check passed. 0% implementation tests (threshold: 30%). All 5 new tests verify observable behavioral contracts — index correctness, URL inclusion in footer output, and empty-input not-found semantics. Test inflation was detected but is non-blocking and contextually explained by the nature of this cleanup PR.

🧪 Test quality analysis by Test Quality Sentinel · 77.7 AIC · ⊞ 8.3K ·

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 78/100. Test quality is acceptable — 0% of new tests are implementation tests (threshold: 30%).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The production changes are correct — both the destructuring refactor and template literal substitution are semantically equivalent to the original code, with no behavioral difference.

Review summary

Production code (update_pr_description_helpers.cjs)

Both changes are pure style refactors:

  • Destructuring { detectionCaution } from assembleMarkdownBodyParts(...) is exactly equivalent to chaining .detectionCaution on the result.
  • Template literal `${detectionCaution}\n\n${sanitizedNewContent}` is exactly equivalent to the string concatenation it replaces.

No logic change, no new code path, no new risk.

Tests (update_pr_description_helpers.test.cjs)

Four of the five new tests are solid:

  • historyUrl propagation through buildAIFooter — correctly validates the third argument is forwarded.
  • findIsland boundary tests (full-body island, empty body, prefix offset) — these pin exact index semantics against the real indexOf-based implementation, which is exactly the right approach for a function whose return values are used in substring() calls.

One non-blocking observation is left inline on the fifth test.

🔎 Code quality review by PR Code Quality Reviewer · 98.8 AIC · ⌖ 7.21 AIC · ⊞ 5.1K

expect(footer).toContain(historyUrl);
});

it("should return a non-empty footer string", () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant test: this it block adds no regression protection beyond what adjacent tests already provide.

💡 Details

Every other buildAIFooter test (e.g. line 22, which asserts toContain("Test Workflow") and toContain(runUrl)) already implicitly proves the function returns a non-empty string. If buildAIFooter broke and returned undefined or "", those tests would fail first.

The expect(typeof footer).toBe("string") assertion is a no-op: TypeScript enforces this at compile time, and if it somehow weren't a string at runtime, footer.length would throw or return undefined, failing toBeGreaterThan(0) on its own.

Consider replacing this with a more targeted assertion — for example verifying the footer contains the <!-- gh-aw-agentic-workflow: ... --> XML marker or the Generated by prefix — so this slot in the suite actually catches a novel failure mode.

@github-actions

Copy link
Copy Markdown
Contributor Author

@copilot please summarize the remaining blockers and next step so this PR can get back to review.

Generated by 👨‍🍳 PR Sous Chef · 55.7 AIC · ⌖ 1 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor Author

@copilot review all comments and address unresolved review feedback, starting with the redundant footer assertion.

Generated by 👨‍🍳 PR Sous Chef · 61 AIC · ⌖ 1.03 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor Author

Please summarize the remaining blockers and the next fix after the review comments are handled.

Generated by 👨‍🍳 PR Sous Chef · 61 AIC · ⌖ 1.03 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor Author

@copilot refresh the branch and rerun checks so the unstable merge state can clear.

Generated by 👨‍🍳 PR Sous Chef · 61.8 AIC · ⌖ 1.21 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor Author

``
@copilot review all comments and address unresolved review feedback.

Generated by 👨‍🍳 PR Sous Chef · 67 AIC · ⌖ 1.05 AIC · ⊞ 17.3K ·

@github-actions

Copy link
Copy Markdown
Contributor Author

``
Please refresh the branch, rerun checks, and replace the redundant footer assertion with a more behavioral test.

Generated by 👨‍🍳 PR Sous Chef · 67 AIC · ⌖ 1.05 AIC · ⊞ 17.3K ·

@pelikhan pelikhan merged commit 63b95a1 into main Jun 21, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants